﻿using IService.Front;

namespace Service.Front
{
    public class CommonService : BaseService<TCustomerProtocol>, ICommonService
    {
        public CommonService(IUnitOfWorkService unitOfWorkService) : base(unitOfWorkService)
        {
        }

        public async Task<RM_FrontApiReturn<dynamic>> GetCustom()
        {
            //获取内容
            var result = await _DbContext.Queryable<TCustomerProtocol>().FirstAsync();
            var content = "";

            if (result != null)
            {
                var lang = _UnitOfWorkService.GetTenantKey();
                if (lang == "en")
                {
                    content = result.EnAgreementContent;
                }
                else if (lang == "tw")
                {
                    content = result.AgreementContent;
                }
            }

            //返回结果
            return _ResultHelper.BuildSuccess(content).Adapt<RM_FrontApiReturn<dynamic>>();
        }
    }
}